home *** CD-ROM | disk | FTP | other *** search
- Path: gail.ripco.com!mambuhl
- From: mambuhl@ripco.com (Martin Ambuhl)
- Newsgroups: comp.lang.c
- Subject: How to get a random strin
- Date: 16 Feb 1996 06:51:57 GMT
- Organization: Ripco Communications, Inc.
- Message-ID: <4g19id$p7n@gail.ripco.com>
- NNTP-Posting-Host: golden.ripco.com
-
- chancl@nevada.edu (Clapton Chan) in <4fh5od$qq0@news.nevada.edu> asks:
-
- >I try to figure out how to get a different string when
- >I run the following program. So far, I always get the
- >second string, though I've used the rand() function.
-
- 0) Get the FAQ from rtfm.mit.edu. You should have already done this.
-
- 1) Your code is missing
- #include <stdlib.h>
-
- 2) for the following, also
- #include <time.h>
- and somewhere shortly after the declarations in main(), insert
- srand(time(NULL));
-
- [A poor practice follows]
- if you do not #include <time.h>, you need
- srand((unsigned)time(NULL));
-
- --
- * Martin Ambuhl net: mambuhl@ripco.com
- * Chicago, IL (USA)
-